package jmine.tec.utils.cripto.cipher;

import javax.crypto.Cipher;

import org.springframework.beans.factory.FactoryBean;

/**
 * {@link FactoryBean} para gerar instancias de {@link Cipher}. Nao eh um singleton
 * 
 * @author takeshi
 */
public class CipherFactoryBean implements FactoryBean {

    private String algorithm;

    /**
     * @return the algorithm
     */
    public String getAlgorithm() {
        return algorithm;
    }

    /**
     * @param algorithm the algorithm to set
     */
    public void setAlgorithm(String algorithm) {
        this.algorithm = algorithm;
    }

    /**
     * {@inheritDoc}
     */
    public Object getObject() throws Exception {
        return Cipher.getInstance(getAlgorithm());
    }

    /**
     * {@inheritDoc}
     */
    public Class getObjectType() {
        return Cipher.class;
    }

    /**
     * {@inheritDoc}
     */
    public boolean isSingleton() {
        return false;
    }

}
